import { CircleBarTableButtonItem } from '@app-base/common/widgets/CircleBar/types';
import {
  filterButtonsByEnvironment,
  filterButtonsByFeatureFlag,
  filterButtonsBySearchText,
  getButtonList,
} from './buttonUtils';

/**
 * 获取所有按钮
 */
export const getAllButtons = (
  omitViewer: boolean = true,
): CircleBarTableButtonItem[] => {
  return getButtonList(omitViewer);
};

/**
 * 过滤按钮列表
 */
export const getFilteredButtonList = (
  allButtons: CircleBarTableButtonItem[],
  environment: string,
  searchText: string,
): CircleBarTableButtonItem[] => {
  // 应用环境过滤器
  let filteredButtons = filterButtonsByEnvironment(allButtons, environment);

  // 应用功能标志过滤器
  filteredButtons = filterButtonsByFeatureFlag(filteredButtons);

  // 应用搜索文本过滤器
  if (searchText) {
    filteredButtons = filterButtonsBySearchText(filteredButtons, searchText);
  }

  return filteredButtons;
};
